<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui" xmlns="http://www.w3.org/1999/xhtml"
	xml:lang="en" lang="en"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
	<ui:composition template="/protegido/main.xhtml">
		<ui:define name='conteudoPrincipal'>
			<script type="text/javascript" charset="utf-8">
				$(document).ready(
						function() {
							$("#navigation li.disciplinasProf a").addClass(
							"active");
					$("#navigation li").parent().find('li')
							.removeClass("active");
					if ($("#disciplinasProf")) {
						$("#disciplinasProf").addClass("active");
					}});
			</script>
			<style type="text/css">
#duas-colunas {
	magin-bottom: 50px;
	min-height: 50px;
}

#duas-colunas .esq {
	float: left;
}

#duas-colunas .dir {
	float: left;
	margin-left: 25px;
}

#duas-colunas .botao {
	float: left;
	margin-left: 25px;
	padding-top: 13px;
}

input {
	width: 180px;
}
</style>
			<h2>Disciplinas Ministradas</h2>

			<h:form prependId="false">
				<div id="campos-busca">
					<div id="duas-colunas">
						<div class="esq">
							<label for="nome">Nome:</label><br />
							<h:inputText type="text" name="nome" value="#{bNome}" id="nome">
							</h:inputText>
						</div>
						<div class="dir">
							<label for="semestre">Semestre:</label><br />
							<h:inputText type="text" name="semestre" value="#{bSemestre}"
								id="semestre">
							</h:inputText>
						</div>
						<div class="botao">
							<h:commandButton type="submit" name="buscar" class="submit"
								value="Buscar" id="buscar" update=":listaDisciplinas">
								<f:setPropertyActionListener target="#{disciplinaMB.bNome}"
									value="#{bNome}" />
								<f:setPropertyActionListener target="#{disciplinaMB.bSemestre}"
									value="#{bSemestre}" />
							</h:commandButton>
						</div>
					</div>
					<c:if test="#{disciplinaMB.bNome !=''  }">
						<small style="font-size: 0.8em;">*Para listar todas as
							disciplinas ministradas, deixe em branco o campo nome, em
							seguida, pressione botão buscar.</small>
					</c:if>
					<c:if test="#{usuarioMB.bNome ==''}">
						<small style="font-size: 0.8em;">*Todas as disciplinas
							ministradas estão sendo listadas.</small>
					</c:if>
				</div>

			</h:form>
			<h:form id="disciplinasForm" prependId="false">
				<table border="0" cellpadding="0" cellspacing="0" width="100%"
					style="font-size: 12px;" id="listaDisciplinas">

					<tbody>
						<tr class="even">
							<th scope="col" style="width: 30%;">Nome</th>
							<th scope="col" style="width: 30%;">Semestre</th>
							<th scope="col" style="width: 30%;">Sendo Ministrada?</th>
							<th scope="col" style="width: 10%;">Ações</th>
						</tr>
						<c:choose>

							<c:when test="#{disciplinaMB.profDisciplinas.size() > 0}">
								<c:forEach items="${disciplinaMB.profDisciplinas}" var="d">
									<tr>
										<td scope="col" style="width: 30%;"><h:commandLink
												value="#{d.nome}"
												action="#{disciplinaMB.detalharDisciplina(d.id)}" /></td>
										<td scope="col" style="width: 30%;"><h:outputText
												value="#{d.semestre}" /></td>

										<td scope="col" style="width: 30%;"><h:outputText
												value="#{(d.status) ? 'Sim' : 'Não'}" /></td>
										<td scope="col" style="width: 10%;"><h:commandLink
												title="Detalhar dados da disciplina" value=" "
												styleClass="detalhar"
												action="#{disciplinaMB.detalharDisciplina(d.id)}" /></td>
									</tr>
								</c:forEach>
							</c:when>
							<c:otherwise>
								<br />
								<tr>
									<td colspan="4">Nenhuma disciplina encontrada.<br />
									</td>
								</tr>
							</c:otherwise>
						</c:choose>
						<tr class="even">
							<th colspan="1" style="text-align: left;"></th>
							<th colspan="3" style="text-align: right;">#{disciplinaMB.disciplinas.size()}
								disciplina(s) encontrada(s).</th>
						</tr>
					</tbody>
				</table>
			</h:form>
		</ui:define>
	</ui:composition>
</h:body>
</html>